From f4bf3c30da92e4ecff5e4d3ad59b5d79901abf5f Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Tue, 15 Jul 2003 09:22:29 +0000 Subject: [PATCH] bitkeeper revision 1.353 (3f13c7d5NDWHAyq2VYrx7Mqs7QYIfQ) vga.h, keyboard.h, setup.c, ioport.c: Cleanups. --- .../arch/xeno/kernel/ioport.c | 42 +++----------- .../arch/xeno/kernel/setup.c | 5 +- .../include/asm-xeno/keyboard.h | 19 ++----- .../include/asm-xeno/vga.h | 56 ++++++++----------- 4 files changed, 39 insertions(+), 83 deletions(-) diff --git a/xenolinux-2.4.21-sparse/arch/xeno/kernel/ioport.c b/xenolinux-2.4.21-sparse/arch/xeno/kernel/ioport.c index 2dd89e4a11..76c412883f 100644 --- a/xenolinux-2.4.21-sparse/arch/xeno/kernel/ioport.c +++ b/xenolinux-2.4.21-sparse/arch/xeno/kernel/ioport.c @@ -6,15 +6,17 @@ #include -asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on) +asmlinkage int sys_iopl(unsigned int new_io_pl) { - unsigned int new_io_pl = (turn_on)?3:0; unsigned int old_io_pl = current->thread.io_pl; dom0_op_t op; if ( !(start_info.flags & SIF_PRIVILEGED) ) return -EPERM; + if ( new_io_pl > 3 ) + return -EINVAL; + /* Need "raw I/O" privileges for direct port access. */ if ( (new_io_pl > old_io_pl) && !capable(CAP_SYS_RAWIO) ) return -EPERM; @@ -23,8 +25,6 @@ asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on) if ( (new_io_pl == 0) && (start_info.flags & SIF_PRIVILEGED) ) new_io_pl = 1; - printk("ioperm not properly supported - set iopl to %d\n",new_io_pl); - /* Change our version of the privilege levels. */ current->thread.io_pl = new_io_pl; @@ -38,35 +38,11 @@ asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on) } -asmlinkage int sys_iopl(unsigned long unused) +asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on) { - struct pt_regs *regs = (struct pt_regs *)&unused; - unsigned int new_io_pl = regs->ebx; - unsigned int old_io_pl = current->thread.io_pl; - dom0_op_t op; - - if ( !(start_info.flags & SIF_PRIVILEGED) ) - return -EPERM; - - if ( new_io_pl > 3 ) - return -EINVAL; - - /* Need "raw I/O" privileges for direct port access. */ - if ( (new_io_pl > old_io_pl) && !capable(CAP_SYS_RAWIO) ) - return -EPERM; - - /* Maintain OS privileges even if user attempts to relinquish them. */ - if ( (new_io_pl == 0) && (start_info.flags & SIF_PRIVILEGED) ) - new_io_pl = 1; - - /* Change our version of the privilege levels. */ - current->thread.io_pl = new_io_pl; + unsigned int new_io_pl = turn_on ? 3 : 0; + printk("ioperm not fully supported - set iopl to %d\n", new_io_pl); + return sys_iopl(new_io_pl); +} - /* Force the change at ring 0. */ - op.cmd = DOM0_IOPL; - op.u.iopl.domain = start_info.dom_id; - op.u.iopl.iopl = new_io_pl; - HYPERVISOR_dom0_op(&op); - return 0; -} diff --git a/xenolinux-2.4.21-sparse/arch/xeno/kernel/setup.c b/xenolinux-2.4.21-sparse/arch/xeno/kernel/setup.c index 51dbe125b0..1fe945976e 100644 --- a/xenolinux-2.4.21-sparse/arch/xeno/kernel/setup.c +++ b/xenolinux-2.4.21-sparse/arch/xeno/kernel/setup.c @@ -166,7 +166,8 @@ void __init setup_arch(char **cmdline_p) ROOT_DEV = MKDEV(RAMDISK_MAJOR,0); memset(&drive_info, 0, sizeof(drive_info)); memset(&screen_info, 0, sizeof(screen_info)); - // this is drawn from a dump from vgacon:startup in standard linux + + /* This is drawn from a dump from vgacon:startup in standard Linux. */ screen_info.orig_video_mode = 3; screen_info.orig_video_isVGA = 1; screen_info.orig_video_lines = 25; @@ -321,7 +322,7 @@ void __init setup_arch(char **cmdline_p) if( !(start_info.flags & SIF_PRIVILEGED) ) panic("Xen granted us console access but not privileged status"); -#ifdef CONFIG_VT +#if defined(CONFIG_VT) #if defined(CONFIG_VGA_CONSOLE) conswitchp = &vga_con; #elif defined(CONFIG_DUMMY_CONSOLE) diff --git a/xenolinux-2.4.21-sparse/include/asm-xeno/keyboard.h b/xenolinux-2.4.21-sparse/include/asm-xeno/keyboard.h index e8a3905b7b..edbd4e3f94 100644 --- a/xenolinux-2.4.21-sparse/include/asm-xeno/keyboard.h +++ b/xenolinux-2.4.21-sparse/include/asm-xeno/keyboard.h @@ -56,32 +56,24 @@ extern unsigned char pckbd_sysrq_xlate[128]; static inline int xen_kbd_controller_present () { - if( start_info.flags & SIF_CONSOLE ) - { - printk("Enable keyboard\n"); - return 1; - } - else - return 0; + return start_info.flags & SIF_CONSOLE; } /* resource allocation */ #define kbd_request_region() do { } while (0) #define kbd_request_irq(handler) request_irq(_EVENT_KBD, handler, 0, "PS/2 kbd", NULL) -// could implement these with command to xen to filter mouse stuff... +/* could implement these with command to xen to filter mouse stuff... */ #define aux_request_irq(hand, dev_id) 0 #define aux_free_irq(dev_id) do { } while(0) /* Some stoneage hardware needs delays after some operations. */ #define kbd_pause() do { } while(0) - static unsigned char kbd_current_scancode = 0; static unsigned char kbd_read_input(void) { - //xprintk("kbd_read_input: returning scancode 0x%2x\n", kbd_current_scancode); return kbd_current_scancode; } @@ -89,13 +81,12 @@ static unsigned char kbd_read_status(void) { long res; res = HYPERVISOR_kbd_op(KBD_OP_READ,0); - if(res<0) { - //printk("kbd_read_status: error from hypervisor: %d", res); + if ( res<0 ) + { kbd_current_scancode = 0; - return 0; // error with our request - wrong domain? + return 0; /* error with our request - wrong domain? */ } kbd_current_scancode = KBD_CODE_SCANCODE(res); - //printk("kbd_read_status: returning status 0x%2x\n", KBD_CODE_STATUS(res)); return KBD_CODE_STATUS(res); } diff --git a/xenolinux-2.4.21-sparse/include/asm-xeno/vga.h b/xenolinux-2.4.21-sparse/include/asm-xeno/vga.h index 7d25414050..fb3605e55e 100644 --- a/xenolinux-2.4.21-sparse/include/asm-xeno/vga.h +++ b/xenolinux-2.4.21-sparse/include/asm-xeno/vga.h @@ -11,42 +11,30 @@ extern unsigned char *vgacon_mmap; - static unsigned long VGA_MAP_MEM(unsigned long x) { - - if( vgacon_mmap == NULL ) - { - /* This is our first time in this function. This whole thing - is a rather grim hack. We know we're going to get asked - to map a 32KB region between 0xb0000 and 0xb8000 because - that's what VGAs are. We used the boot time permanent - fixed map region, and map it to machine pages. - */ - - if( x != 0xb8000 ) - { - printk("Argghh! VGA Console is weird. 1:%08lx\n",x); - BUG(); - } - - vgacon_mmap = (unsigned char*) bt_ioremap( 0xb8000, 32*1024 ); -//xprintk("VGA_MAP_MEM(%08x) first. return %p\n",x,vgacon_mmap); - return (unsigned long) vgacon_mmap; - } - else - { - if( x != 0xc0000 ) - { - printk("Argghh! VGA Console is weird. 2:%08lx\n",x); - BUG(); - } -//xprintk("VGA_MAP_MEM(%08x) second. return %p\n",x,(unsigned long) vgacon_mmap+0x8000); - - return (unsigned long) vgacon_mmap + 0x8000; - - } - return 0; + if( vgacon_mmap == NULL ) + { + /* This is our first time in this function. This whole thing + is a rather grim hack. We know we're going to get asked + to map a 32KB region between 0xb0000 and 0xb8000 because + that's what VGAs are. We used the boot time permanent + fixed map region, and map it to machine pages. + */ + if( x != 0xb8000 ) + panic("Argghh! VGA Console is weird. 1:%08lx\n",x); + + vgacon_mmap = (unsigned char*) bt_ioremap( 0xb8000, 32*1024 ); + return (unsigned long) vgacon_mmap; + } + else + { + if( x != 0xc0000 ) + panic("Argghh! VGA Console is weird. 2:%08lx\n",x); + + return (unsigned long) vgacon_mmap + 0x8000; + } + return 0; } static inline unsigned char vga_readb(unsigned char * x) { return (*(x)); } -- 2.30.2